package org.imj.service;

import java.util.logging.Logger;
import com.google.inject.Inject;

import org.imj.model.State;
import org.imj.dao.StateDAO;


public class StateService {
	
	@Inject
	private StateDAO stateDAO;
	
	@Inject
	private Logger logger;
	
	public boolean addState(State state){
		if(state == null){
			logger.warning("State is NULL!");
			return false;
		}else {
			stateDAO.insert(state);
			return true;
		}
	}
	
	public State getStateById(int id){
		int maxId = stateDAO.getMaxId();
		if(maxId < 0 || maxId < id){
			logger.warning("The state with id: " + id + " does NOT exist!");
			return null;
		}else
			return stateDAO.getById(id);
	}
	
}
